#include <iostream>
#include <vector>
#include <string>

using namespace std;


int main()
{
	string s;
	string a, b;
	int k;

	int ret = 0;
	int temp = 0;
	cin >> k >> s >> a >> b ;

	int n = s.size();

	for (int i = n-1; i >= 0; i--)
	{
		if (s[i] == b[0] )
		{
			temp = 0;
			for (int j = i - k + 1; j >= 0; j--)
			{
				if (s[j] == a[0])
				{
					temp++;
				}
			}
			ret += temp;
		}
	}

	cout << ret << endl;

	return 0;
}